package xxl.robotlegs.extensions.enhancedlogging 
{
	import org.flashdevelop.utils.FlashDevelopIDE;
	import xxl.robotlegs.extensions.enhancedlogging.impl.*;
	import xxl.robotlegs.framework.api.IContext;
	import xxl.robotlegs.framework.api.IExtension;
	
	/**
	 * ...
	 * @author XXL
	 */
	public class TraceLoggingExtension implements IExtension 
	{
		
		public function TraceLoggingExtension() 
		{
			
		}
		
		public function toString():String
		{
			return "TraceLoggingExtension（简介：提供了一个以trace实现的日志输出终端，使用FlashDevelopIDE下将使用FlashConnect的输出）";
		}
		
		/* INTERFACE xxl.robotlegs.framework.api.IExtension */
		
		public function extend(context:IContext):void 
		{
			var flashDevelopIDE:FlashDevelopIDE = new FlashDevelopIDE();
			if (flashDevelopIDE.available)
			{
				context.addLogTarget(new FlashDevelopOutputTarget(context));
			}
			else
			{
				context.addLogTarget(new TraceLogTarget(context));
			}
			context.getLogger(this).debug("安装了 {0}（因为扩展安装是先发日志后安装的，要安装完本扩展后才能trace出信息，所以自己再额外追加一条日志，以供打印输出）", [this]);
		}
		
	}

}